﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QToolButton>
#include <QGraphicsView>
#include <QToolBar>
#include <QAction>
#include <QMenu>
#include <QTableWidget>
#include "mgd_car_object.h"
#include "mcn_car_object.h"
#include "mfs_car_object.h"
#include "mbasescene.h"
#include "mbaseview.h"
#include "netconnection.h"

QT_BEGIN_NAMESPACE
namespace Ui
{
    class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget* parent = nullptr);
    ~MainWindow();

    void SceneState(QGraphicsScene* scene);

    //状态表格的生成函数
    void ForStateWidget();
    void SetupStateWidget();

private:
    QStringList* CarNumberList;



private:
    QAction* exitAction;
    QAction* logsAction;
    QAction* connectAction;
    QAction* exportAction;
    QAction* ImportAction;

    QMenu* fileMenu;
    QMenu* setMenu;


    QToolButton* mouseToolbtn;
    QToolBar* mouseToolbar;

    QToolButton* centerToolbtn;
    QToolBar* centerToolbar;

    QToolButton* TLeftToolbtn;
    QToolButton* TRightToolbtn;
    QToolButton* DeleteToolbtn;
    QToolBar* ItemOpToolbar;

    QToolButton* StateToolbtn;
    QToolBar* StateToolbar;


    QToolButton* LoadToolbtn;
    QToolBar* LoadToolbar;


    void creatAction();//动作
    void creatMenus();//菜单栏
    void creatToolbars();//功能栏目
    void itemWeidgetInit();//选项栏目


    MBaseScene* scene;

    QToolButton* CursorButton;
    QToolButton* LineButton;
    QToolButton* GD_carButton;
    QToolButton* CN_carButton;
    QToolButton* FS_carButton;


    NetConnection* NetWidget;
    QWidget* ItemWidget;
    MBaseView* view;

    //当前场景的状态表格的生成
    QTableWidget* StateWidget;

    //接受状态信息，对UI界面进行改变
    void toNewCNcar(QString carIP, QString mCarState, QList<mCN_car_object*> CNitemList);
    void toNewFScar(QString carIP, QString mCarState, QList<mFS_car_object*> FSitemList);
    void toNewGDcar(QString carIP, QString mCarState, QList<mGD_car_object*> GDitemList);


signals:
    void signalAllisAtOrigin(Line_Object* item);
    void signaltheSocketisAtOrigin(Line_Object* item);

private slots:
    void slotButGD_car();
    void slotButCN_car();
    void slotButFS_car();
    void slotButLine();
    void slotLineTomouse();
    void slotSceneState();
    void slotCenterOn();
    void slotTLeft();
    void slotTRight();
    void slotDelete();
    void slotReallyDel(Line_Object* item);
    void slotStateForm();
    void slotStateToNew();
    void slotNetshow();
    void slotgetCarState(QString carState);
    //临时借用，暂时作为本地的导出导入使用
    void slotSceneSave();
    void slotSceneImport();
    void slotStateToSend();
    void slotSceneStateShow(QString SceneState);

    void slotLoadtodo();
    void slotToNewLineColor();

    void slotToSendtheSocketisAtOrigin(Line_Object* item);


private:
    Ui::MainWindow* ui;
};
#endif // MAINWINDOW_H
